package T31_T40;

import datastructure.TreeNode;
public class T37 {
        private int maxDeep = 0; // 存储最大深度
        public int maxDepth(TreeNode root) {
            loginDepth(root, 1);
            return maxDeep;
        }
        private void loginDepth(TreeNode node, int depth) {
            if (node == null) return;
            maxDeep = Math.max(maxDeep, depth); // 记录最大深度
            loginDepth(node.left, depth + 1);
            loginDepth(node.right, depth + 1);
        }
}
